package com.icinfo.cloud.provider.punish.ucase.punishexecute.controller;

import com.icinfo.cloud.common.core.Validator.BaseGroup;
import com.icinfo.cloud.provider.punish.ucase.punishexecute.dto.CaseDelayInstallmentDetailDto;
import com.icinfo.cloud.provider.punish.ucase.punishexecute.dto.CaseDelayInstallmentDocDto;
import com.icinfo.cloud.provider.punish.ucase.punishexecute.dto.CaseDelayInstallmentDto;
import com.icinfo.cloud.provider.punish.ucase.punishexecute.dto.CaseDelayInstallmentPunishMoneyDto;
import com.icinfo.cloud.provider.punish.ucase.punishexecute.service.ICaseDelayInstallmentService;
import com.icinfo.cloud.provider.punish.ucase.punishexecute.vo.CaseDelayInstallmentDocVo;
import com.icinfo.cloud.provider.punish.ucase.punishexecute.vo.CaseDelayInstallmentVo;
import com.icinfo.framework.common.web.Result;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 申请延期（分期）缴纳罚款controller
 * @Author mahan
 * @Date 2022/9/20
 * @Version 1.0
 */
@RestController
@RequestMapping("/punish/ucase/delayInstallment")
public class CaseDelayInstallmentController {

    @Resource
    private ICaseDelayInstallmentService caseDelayInstallmentService;


    /**
     * 新增延期（分期）
     * @param caseDelayInstallmentDto
     * @return
     */
    @PostMapping("/saveDelayInstallment")
    public Result<CaseDelayInstallmentDocVo> saveDelayInstallment(@RequestBody @Validated(BaseGroup.Insert.class) CaseDelayInstallmentDto caseDelayInstallmentDto) {
        return Result.success(caseDelayInstallmentService.saveDelayInstallment(caseDelayInstallmentDto));
    }

    /**
     * 修改延期（分期）
     * @param caseDelayInstallmentDto
     * @return
     */
    @PostMapping("/updateDelayInstallment")
    public Result<CaseDelayInstallmentDocVo> updateDelayInstallment(@RequestBody @Validated(BaseGroup.Update.class) CaseDelayInstallmentDto caseDelayInstallmentDto) {
        return Result.success(caseDelayInstallmentService.updateDelayInstallment(caseDelayInstallmentDto));
    }

    /**
     * 延期（分期）详情
     * @param dto
     * @return
     */
    @PostMapping("/delayInstallmentInfo")
    public Result<CaseDelayInstallmentVo> delayInstallmentInfo(@RequestBody @Validated CaseDelayInstallmentDetailDto dto) {
        return Result.success(caseDelayInstallmentService.delayInstallmentInfo(dto));
    }

    /**
     * 延期（分期）文书字段查询
     * @param dto
     * @return
     */
    @PostMapping("/delayInstallmentDocInfo")
    public Result<CaseDelayInstallmentDocVo> delayInstallmentDocInfo(@RequestBody @Validated CaseDelayInstallmentDocDto dto) {
        return Result.success(caseDelayInstallmentService.delayInstallmentDocInfo(dto));
    }

    /**
     * 获取案件处罚金额
     * @param dto
     * @return
     */
    @PostMapping("/getCasePunishMoney")
    public Result<String> getCasePunishMoney(@RequestBody @Validated CaseDelayInstallmentPunishMoneyDto dto) {
        return Result.success("操作成功", caseDelayInstallmentService.getCasePunishMoney(dto));
    }

    /**
     * 测试使用
     * @param caseId
     * @return
     */
    //@GetMapping("/test")
    public Result<List<CaseDelayInstallmentVo>> getCasePunishMoney(@RequestParam("caseId") String caseId) {
        return Result.success("操作成功", caseDelayInstallmentService.delayInstallmentInfo(caseId));
    }

}
